#include<stdio.h>
int n;
int f(int a[])
{
	int i,j,max;
	//sap sep tang dan
	for (i=0;i<n;i++)
		for(j=i+1;j<n;j++)
			if(a[i]>a[j])
			{
				max=a[i];
				a[i]=a[j];
				a[j]=max;
			}
     //tim phan tu second largest
     max=a[n-1];
     j=0;
     for (i=n-1;i>0;i--)
     if (a[i]<max)
     {
     	max=a[i];
     	j=1;
     	break;
     }
     if (j) return max;
     else return -1;
}
main()
{
	int a[]={1,1,1,1,1,1,2,2,2,2,3,3,4};
	n=sizeof(a)/sizeof(int);
	printf("%d \n",f(a));	
}
